<?php

declare(strict_types=1);

namespace App\Traits\Model\Orders;



trait OrderGood
{
    /**
     * 设置店铺ID
     * @param $value
     */
    public function setShopIdAttribute($value)
    {
        if (!$value) {
            $value = getShop('id');
        }

        $this->attributes['shop_id'] = $value;
    }

    /**
     * 获取快照
     * @return string
     */
    public function getSnapshotAttribute($value)
    {
        return htmlspecialchars_decode($value?:'');
    }

    /**
     * 获取商品链接
     * @return string
     */
    public function getProductLinkAttribute($value)
    {
        return htmlspecialchars_decode($value?:'');
    }

    /**
     * 获取179号商品信息
     * @return array
     */
    public function toExchangeInfoArray():array
    {
        return [
            'gname' => $this->good['name'],
            'itemLink' => $this->product_link
        ];
    }
}
